<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1>6.html</h1>

  <button onclick="save()">save</button>
  <button onclick="read()">read</button>
  <button onclick="remove()">remove gender</button>
  <button onclick="empty()">clear</button>

  <a href="./7.html">7.html</a>
  <script>
    const info = { username: 'jack', age: 20, gender: 'boy' };
    function save() {
      sessionStorage.info = JSON.stringify(info);
    }
    function read() {
      console.log("sessionStorage.info: ", JSON.parse(sessionStorage.info));
    }
    function remove() {
      sessionStorage.removeItem('gender');
    }

    function empty() {
      sessionStorage.clear();
    }
  </script>
</body>

</html>